#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <aclconio.h>
#include <define.h>
#include <transact.h>
#include <tran.h>
#include <gds.h>
#include <sizes.h>
#include "ConfProto.h"
#include "tblutil.h"
#include <\SOFTPAY\Ver30\source\include\sizes.h>
#include <\SOFTPAY\Ver30\HostSrc\citisrc\citiids.h>
#include <\SOFTPAY\Ver30\HostSrc\cpacsrc\cpacids.h>
#include <confio.h>

#include <\SOFTPAY\Ver30\source\include\PCT.h>



static void *storeFromStruct;

static int recordNum;
void registerPCT(void *ptr)
{
	 storeFromStruct = ptr;
}

void *dealWithAddressBoundary(void*address);
int	inLoadPCTRecFromStruct (int inRecNumber, void *vdStruct)
{
	int inRet;
	char* tmp = (char*)vdStruct;

	registerPCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inLoadConfRec(PCT_FILENAME, SIZE_PCT_REC, inRecNumber, vdStruct);

	recordNum = inRecNumber;
	return inRet;
}

void vdRestorePCTRecFromStruct(void *vdStruct)
{
	registerPCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	memcpy((char *) pvdGetPCTRec(), vdStruct, SIZE_PCT_REC);

}

void vdCopyPCTRecFromStruct(void *vdStruct)
{
	registerPCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
		memcpy(vdStruct, (char *) pvdGetPCTRec(), SIZE_PCT_REC);

}

int	inSavePCTRecFromStruct (int inRecNumber,  void *vdStruct)
{
	int inRet;

	registerPCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(PCT_FILENAME, SIZE_PCT_REC, inRecNumber, (char *) vdStruct);

	return inRet;
}

int	inUpdatePCTRecFromStruct (void *vdStruct)
{
	int inRet;

	registerPCT(vdStruct);
	vdStruct = dealWithAddressBoundary(vdStruct);
	inRet = inSaveConfRec(PCT_FILENAME, SIZE_PCT_REC, recordNum, (char *) vdStruct);

	return inRet;
}

char* szGetRctHdr2FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctHdr2();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctHdr2;
}

void vdSetRctHdr2FromStruct(const char* szRctHdr2, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctHdr2(szRctHdr2);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctHdr2, szRctHdr2, sizeof(((PCT_REC*)NULL)->szRctHdr2)-1);
}

char* szGetRctHdr3FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctHdr3();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctHdr3;
}

void vdSetRctHdr3FromStruct(const char* szRctHdr3, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctHdr3(szRctHdr3);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctHdr3, szRctHdr3, sizeof(((PCT_REC*)NULL)->szRctHdr3)-1);
}

char* szGetRctHdr4FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctHdr4();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctHdr4;
}

void vdSetRctHdr4FromStruct(const char* szRctHdr4, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctHdr4(szRctHdr4);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctHdr4, szRctHdr4, sizeof(((PCT_REC*)NULL)->szRctHdr4)-1);
}

char* szGetRctHdr5FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctHdr5();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctHdr5;
}

void vdSetRctHdr5FromStruct(const char* szRctHdr5, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctHdr5(szRctHdr5);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctHdr5, szRctHdr5, sizeof(((PCT_REC*)NULL)->szRctHdr5)-1);
}

char* szGetRctFoot1FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctFoot1();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctFoot1;
}

void vdSetRctFoot1FromStruct(const char* szRctFoot1, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctFoot1(szRctFoot1);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctFoot1, szRctFoot1, sizeof(((PCT_REC*)NULL)->szRctFoot1)-1);
}

char* szGetRctFoot2FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctFoot2();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctFoot2;
}

void vdSetRctFoot2FromStruct(const char* szRctFoot2, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctFoot2(szRctFoot2);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctFoot2, szRctFoot2, sizeof(((PCT_REC*)NULL)->szRctFoot2)-1);
}

char* szGetRctFoot3FromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return szGetRctFoot3();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->szRctFoot3;
}

void vdSetRctFoot3FromStruct(const char* szRctFoot3, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetRctFoot3(szRctFoot3);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	strNumCopy(((PCT_REC*)vdStruct)->szRctFoot3, szRctFoot3, sizeof(((PCT_REC*)NULL)->szRctFoot3)-1);
}

short inGetPrinterTypeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetPrinterType();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inPrinterType;
}

void vdSetPrinterTypeFromStruct(short inPrinterType, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPrinterType(inPrinterType);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inPrinterType = inPrinterType;
}

short inGetP350ColModeFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetP350ColMode();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inP350ColMode;
}

void vdSetP350ColModeFromStruct(short inP350ColMode, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetP350ColMode(inP350ColMode);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inP350ColMode = inP350ColMode;
}

short inGetCommIndexFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetCommIndex();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inCommIndex;
}

void vdSetCommIndexFromStruct(short inCommIndex, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCommIndex(inCommIndex);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inCommIndex = inCommIndex;
}

short inGetPrintOptionFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetPrintOption();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inPrintOption;
}

void vdSetPrintOptionFromStruct(short inPrintOption, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPrintOption(inPrintOption);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inPrintOption = inPrintOption;
}

short inGetCustCopyOptionFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetCustCopyOption();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inCustCopyOption;
}

void vdSetCustCopyOptionFromStruct(short inCustCopyOption, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetCustCopyOption(inCustCopyOption);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inCustCopyOption = inCustCopyOption;
}

short inGetPromptBeepDelayFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetPromptBeepDelay();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inPromptBeepDelay;
}

void vdSetPromptBeepDelayFromStruct(short inPromptBeepDelay, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPromptBeepDelay(inPromptBeepDelay);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inPromptBeepDelay = inPromptBeepDelay;
}

short inGetP350LinesPerInchFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return inGetP350LinesPerInch();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->inP350LinesPerInch;
}

void vdSetP350LinesPerInchFromStruct(short inP350LinesPerInch, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetP350LinesPerInch(inP350LinesPerInch);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->inP350LinesPerInch = inP350LinesPerInch;
}

VS_BOOL fGetPrintDisclaimerFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetPrintDisclaimer();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->fPrintDisclaimer;
}

void vdSetPrintDisclaimerFromStruct(VS_BOOL fPrintDisclaimer, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPrintDisclaimer(fPrintDisclaimer);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->fPrintDisclaimer = fPrintDisclaimer;
}

VS_BOOL fGetOpenTabSLineFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetOpenTabSLine();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->fOpenTabSLine;
}

void vdSetOpenTabSLineFromStruct(VS_BOOL fOpenTabSLine, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetOpenTabSLine(fOpenTabSLine);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->fOpenTabSLine = fOpenTabSLine;
}

VS_BOOL fGetClerkSignLineFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetClerkSignLine();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->fClerkSignLine;
}

void vdSetClerkSignLineFromStruct(VS_BOOL fClerkSignLine, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetClerkSignLine(fClerkSignLine);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->fClerkSignLine = fClerkSignLine;
}

VS_BOOL fGetEnablePrinterFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetEnablePrinter();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->fEnablePrinter;
}

void vdSetEnablePrinterFromStruct(VS_BOOL fEnablePrinter, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetEnablePrinter(fEnablePrinter);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->fEnablePrinter = fEnablePrinter;
}

VS_BOOL fGetPrePrintFromStruct(void*vdStruct)
{
	if(vdStruct != storeFromStruct)
		return fGetPrePrint();
	vdStruct = dealWithAddressBoundary(vdStruct);
	return ((PCT_REC*)vdStruct)->fPrePrint;
}

void vdSetPrePrintFromStruct(VS_BOOL fPrePrint, void*vdStruct)
{
	if(vdStruct != storeFromStruct)
	{
		vdSetPrePrint(fPrePrint);
		return;
	}
	vdStruct = dealWithAddressBoundary(vdStruct);
	((PCT_REC*)vdStruct)->fPrePrint = fPrePrint;
}

